<?php
// +----------------------------------------------------------------------
// | webhooks
// +----------------------------------------------------------------------
// | Author: King east <1207877378@qq.com>
// +----------------------------------------------------------------------


namespace ke\route;


class RouteGroup
{
    private $callback;

    private $options = [];

    public function __construct(callable $callback)
    {
        $this->callback = $callback;
    }

    /**
     * 设置命名空间
     * @param string $name
     * @return RouteGroup
     */
    public function setNamespace($name)
    {
        $this->options['namespace'] = $name;
        return $this;
    }


    /**
     * 获取命名空间
     * @return string
     */
    public function getNamespace()
    {
        return $this->options['namespace'] ?? '';
    }

    /**
     * 设置控制器前缀
     * @param string $name
     * @return RouteGroup
     */
    public function setPrefix($name)
    {
        $this->options['prefix'] = $name;
        return $this;
    }

    /**
     * 获取控制器前缀
     * @return string
     */
    public function getPrefix()
    {
        return $this->options['prefix'] ?? '';
    }

    public function call()
    {
        call_user_func($this->callback);
    }
}